package com.gui.controller;

import com.gui.exception.DIYExceptionHandler;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * TestController
 *
 * @author guigu
 * @QQ 1170258867
 * @date 2020/5/25
 * @description 测试springmvc
 */
@Controller
public class TestController {

    @RequestMapping("/hello")
    public  String testHello(/*@RequestParam("name") String name,*/ Model model){
        model.addAttribute("name","name");
        return "hello";
    }

    @RequestMapping("/he")
    public String testError(){
        throw new NullPointerException();
    }

    @RequestMapping("/heDIY")
    public String testErrorDIY() throws DIYExceptionHandler {
        throw new DIYExceptionHandler("这是一个自定义异常");
    }
}
